<?php

class WorkflowInbox
{
  
  /**
   * @var sfGuardUser
   */
  protected $user;
  
  /**
   * @var array
   */
  protected $options = array();
  
  /**
   * @var array
   */
  protected $work_items = null;

  /**
   * @param sfGuardUser $for_user
   * @param array $options
   */
  public function __construct (sfGuardUser $for_user, array $options = array())
  {
    $this->user = $for_user;
    $this->options = $options;
  }

  /**
   * @return array
   */
  public function getWorkItems ()
  {
    if (is_null($this->work_items))
    {
      // Lazy loading
      $work_items = wfWorkflowWorkItemTable::getInstance()->findByUserId($this->user->getId());
      $this->work_items = array();
      foreach ($work_items as $work_item)
      {
        $this->work_items[] = RunTimeWorkflowNodeFactory::getInstance()->create($work_item);
      }
    }
    return $this->work_items;
  }
}